#include "iUiNumStatic.h"

iUiNumStatic::iUiNumStatic(void)
{
}

iUiNumStatic::~iUiNumStatic(void)
{
}

void iUiNumStatic::PaintWin(HDC hdc, RECT* prcWin, RECT* prcUpdate)
{
	RECT rc = *prcWin;
/*
	if(GetState() == MZCS_BUTTON_PRESSED)
	{
		if((m_imgPressed != NULL))
		{
			RECT rcExtend = rc;
			if(m_bIsClipExtend)
			{
				rcExtend.left -= m_rcExtendSize.left;
				rcExtend.top -= m_rcExtendSize.top;
				rcExtend.right += m_rcExtendSize.right;
				rcExtend.bottom += m_rcExtendSize.bottom;
			}
			m_imgPressed->Draw(hdc, &rcExtend, false, false);
		}

	}
	else
	{
		if((m_imgNormal != NULL))
		{
			m_imgNormal->Draw(hdc, &rc, false, false);	
		}
	}
*/
	for(UINT nPos = 0; nPos < GetText().Length(); nPos++)
	{
		RECT rcNumSign;

		switch(GetText().C_Str()[nPos])
		{
		case '0':
			rcNumSign.left = rc.left + m_rtNum[nPos].left;
			rcNumSign.right = rc.left + m_rtNum[nPos].right;
			rcNumSign.top = rc.top + m_rtNum[nPos].top;
			rcNumSign.bottom = rc.top + m_rtNum[nPos].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_ZERO]->Draw(hdc, &rcNumSign, false, false);
			break;
		case '1':
			rcNumSign.left = rc.left + m_rtNum[nPos].left;
			rcNumSign.right = rc.left + m_rtNum[nPos].right;
			rcNumSign.top = rc.top + m_rtNum[nPos].top;
			rcNumSign.bottom = rc.top + m_rtNum[nPos].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_ONE]->Draw(hdc, &rcNumSign, false, false);
			break;
		case '2':
			rcNumSign.left = rc.left + m_rtNum[nPos].left;
			rcNumSign.right = rc.left + m_rtNum[nPos].right;
			rcNumSign.top = rc.top + m_rtNum[nPos].top;
			rcNumSign.bottom = rc.top + m_rtNum[nPos].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_TWO]->Draw(hdc, &rcNumSign, false, false);
			break;
		case '3':
			rcNumSign.left = rc.left + m_rtNum[nPos].left;
			rcNumSign.right = rc.left + m_rtNum[nPos].right;
			rcNumSign.top = rc.top + m_rtNum[nPos].top;
			rcNumSign.bottom = rc.top + m_rtNum[nPos].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_THREE]->Draw(hdc, &rcNumSign, false, false);
			break;
		case '4':
			rcNumSign.left = rc.left + m_rtNum[nPos].left;
			rcNumSign.right = rc.left + m_rtNum[nPos].right;
			rcNumSign.top = rc.top + m_rtNum[nPos].top;
			rcNumSign.bottom = rc.top + m_rtNum[nPos].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_FOUR]->Draw(hdc, &rcNumSign, false, false);
			break;
		case '5':
			rcNumSign.left = rc.left + m_rtNum[nPos].left;
			rcNumSign.right = rc.left + m_rtNum[nPos].right;
			rcNumSign.top = rc.top + m_rtNum[nPos].top;
			rcNumSign.bottom = rc.top + m_rtNum[nPos].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_FIVE]->Draw(hdc, &rcNumSign, false, false);
			break;
		case '6':
			rcNumSign.left = rc.left + m_rtNum[nPos].left;
			rcNumSign.right = rc.left + m_rtNum[nPos].right;
			rcNumSign.top = rc.top + m_rtNum[nPos].top;
			rcNumSign.bottom = rc.top + m_rtNum[nPos].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_SIX]->Draw(hdc, &rcNumSign, false, false);
			break;
		case '7':
			rcNumSign.left = rc.left + m_rtNum[nPos].left;
			rcNumSign.right = rc.left + m_rtNum[nPos].right;
			rcNumSign.top = rc.top + m_rtNum[nPos].top;
			rcNumSign.bottom = rc.top + m_rtNum[nPos].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_SEVEN]->Draw(hdc, &rcNumSign, false, false);
			break;
		case  '8':
			rcNumSign.left = rc.left + m_rtNum[nPos].left;
			rcNumSign.right = rc.left + m_rtNum[nPos].right;
			rcNumSign.top = rc.top + m_rtNum[nPos].top;
			rcNumSign.bottom = rc.top + m_rtNum[nPos].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_EIGHT]->Draw(hdc, &rcNumSign, false, false);
			break;
		case '9':
			rcNumSign.left = rc.left + m_rtNum[nPos].left;
			rcNumSign.right = rc.left + m_rtNum[nPos].right;
			rcNumSign.top = rc.top + m_rtNum[nPos].top;
			rcNumSign.bottom = rc.top + m_rtNum[nPos].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_NINE]->Draw(hdc, &rcNumSign, false, false);
			break;
		case '.':
			rcNumSign.left = rc.left + m_rtNum[nPos].left;
			rcNumSign.right = rc.left + m_rtNum[nPos].right;
			rcNumSign.top = rc.top + m_rtNum[nPos].top;
			rcNumSign.bottom = rc.top + m_rtNum[nPos].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_DOT]->Draw(hdc, &rcNumSign, false, false);
			break;
		case 'k'://KHZ
		case 'K':
			rcNumSign.left = rc.left + m_rtNum[RECT_NUM_SIGN_FREQ_UNIT].left;
			rcNumSign.right = rc.left + m_rtNum[RECT_NUM_SIGN_FREQ_UNIT].right;
			rcNumSign.top = rc.top + m_rtNum[RECT_NUM_SIGN_FREQ_UNIT].top;
			rcNumSign.bottom = rc.top + m_rtNum[RECT_NUM_SIGN_FREQ_UNIT].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_KMZ]->Draw(hdc, &rcNumSign, false, false);
			break;
		case 'm'://MHZ
		case 'M':
			rcNumSign.left = rc.left + m_rtNum[RECT_NUM_SIGN_FREQ_UNIT].left;
			rcNumSign.right = rc.left + m_rtNum[RECT_NUM_SIGN_FREQ_UNIT].right;
			rcNumSign.top = rc.top + m_rtNum[RECT_NUM_SIGN_FREQ_UNIT].top;
			rcNumSign.bottom = rc.top + m_rtNum[RECT_NUM_SIGN_FREQ_UNIT].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_MHZ]->Draw(hdc, &rcNumSign, false, false);
			break;
		case 'a'://FM1
		case 'A':
			rcNumSign.left = rc.left + m_rtNum[RECT_NUM_SIGN_BAND].left;
			rcNumSign.right = rc.left + m_rtNum[RECT_NUM_SIGN_BAND].right;
			rcNumSign.top = rc.top + m_rtNum[RECT_NUM_SIGN_BAND].top;
			rcNumSign.bottom = rc.top + m_rtNum[RECT_NUM_SIGN_BAND].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_FM1]->Draw(hdc, &rcNumSign, false, false);
			break;
		case 'b'://FM2
		case 'B':
			rcNumSign.left = rc.left + m_rtNum[RECT_NUM_SIGN_BAND].left;
			rcNumSign.right = rc.left + m_rtNum[RECT_NUM_SIGN_BAND].right;
			rcNumSign.top = rc.top + m_rtNum[RECT_NUM_SIGN_BAND].top;
			rcNumSign.bottom = rc.top + m_rtNum[RECT_NUM_SIGN_BAND].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_FM2]->Draw(hdc, &rcNumSign, false, false);
			break;
		case 'c'://FM3
		case 'C':
			rcNumSign.left = rc.left + m_rtNum[RECT_NUM_SIGN_BAND].left;
			rcNumSign.right = rc.left + m_rtNum[RECT_NUM_SIGN_BAND].right;
			rcNumSign.top = rc.top + m_rtNum[RECT_NUM_SIGN_BAND].top;
			rcNumSign.bottom = rc.top + m_rtNum[RECT_NUM_SIGN_BAND].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_FM3]->Draw(hdc, &rcNumSign, false, false);
			break;
		case 'd'://AM1
		case 'D':
			rcNumSign.left = rc.left + m_rtNum[RECT_NUM_SIGN_BAND].left;
			rcNumSign.right = rc.left + m_rtNum[RECT_NUM_SIGN_BAND].right;
			rcNumSign.top = rc.top + m_rtNum[RECT_NUM_SIGN_BAND].top;
			rcNumSign.bottom = rc.top + m_rtNum[RECT_NUM_SIGN_BAND].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_AM1]->Draw(hdc, &rcNumSign, false, false);
			break;
		case 'e':
		case 'E'://AM2
			rcNumSign.left = rc.left + m_rtNum[RECT_NUM_SIGN_BAND].left;
			rcNumSign.right = rc.left + m_rtNum[RECT_NUM_SIGN_BAND].right;
			rcNumSign.top = rc.top + m_rtNum[RECT_NUM_SIGN_BAND].top;
			rcNumSign.bottom = rc.top + m_rtNum[RECT_NUM_SIGN_BAND].bottom;
			m_imgNumSign[STATIC_NUM_SIGN_AM2]->Draw(hdc, &rcNumSign, false, false);
			break;
		case 'f'://ST
		case 'F':
/*
			rcNumSign.left = rc.left + m_rtNum[RECT_NUM_SIGN_ST].left;
			rcNumSign.right = rc.left + m_rtNum[RECT_NUM_SIGN_ST].right;
			rcNumSign.top = rc.top + m_rtNum[RECT_NUM_SIGN_ST].top;
			rcNumSign.bottom = rc.top + m_rtNum[RECT_NUM_SIGN_ST].bottom;
*/
			rcNumSign = rc;
			m_imgNumSign[STATIC_NUM_SIGN_ST]->Draw(hdc, &rcNumSign, false, false);
			break;
		case 'g'://LOC
		case 'G':
/*
			rcNumSign.left = rc.left + m_rtNum[RECT_NUM_SIGN_LOC].left;
			rcNumSign.right = rc.left + m_rtNum[RECT_NUM_SIGN_LOC].right;
			rcNumSign.top = rc.top + m_rtNum[RECT_NUM_SIGN_LOC].top;
			rcNumSign.bottom = rc.top + m_rtNum[RECT_NUM_SIGN_LOC].bottom;
*/
			rcNumSign = rc;
			m_imgNumSign[STATIC_NUM_SIGN_LOC]->Draw(hdc, &rcNumSign, false, false);
			break;
		case 'h'://AUTO
		case 'H':
/*
			rcNumSign.left = rc.left + m_rtNum[RECT_NUM_SIGN_AUTO].left;
			rcNumSign.right = rc.left + m_rtNum[RECT_NUM_SIGN_AUTO].right;
			rcNumSign.top = rc.top + m_rtNum[RECT_NUM_SIGN_AUTO].top;
			rcNumSign.bottom = rc.top + m_rtNum[RECT_NUM_SIGN_AUTO].bottom;
*/
			rcNumSign = rc;
			m_imgNumSign[STATIC_NUM_SIGN_AUTO]->Draw(hdc, &rcNumSign, false, false);
			break;
		case 'i'://PTY
		case 'I':
/*
			rcNumSign.left = rc.left + m_rtNum[RECT_NUM_SIGN_PTY].left;
			rcNumSign.right = rc.left + m_rtNum[RECT_NUM_SIGN_PTY].right;
			rcNumSign.top = rc.top + m_rtNum[RECT_NUM_SIGN_PTY].top;
			rcNumSign.bottom = rc.top + m_rtNum[RECT_NUM_SIGN_PTY].bottom;
*/
			rcNumSign = rc;
			m_imgNumSign[STATIC_NUM_SIGN_PTY]->Draw(hdc, &rcNumSign, false, false);
			break;

		default:
			break;
		}
	}
}


void iUiNumStatic::SetNumSignImg(ImagingHelper *pImag[], RECT pRt[])
{
	for(UINT nIndex = 0; nIndex < MAX_STATIC_NUM_SIGN; nIndex++)
	{
		m_imgNumSign[nIndex] = pImag[nIndex];
	}
	for(UINT nRt = 0; nRt < MAX_RECT_NUM_SIGN; nRt++)
	{
		m_rtNum[nRt].left = pRt[nRt].left;
		m_rtNum[nRt].right = pRt[nRt].right;
		m_rtNum[nRt].top = pRt[nRt].top;
		m_rtNum[nRt].bottom = pRt[nRt].bottom;
	}
}